<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  String xm = this.getServletContext().getInitParameter("path");
	String path1 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+xm;
%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新增接待信息</title>
<link href="<%=path1%>/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path1%>/scripts/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.src.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.min.js"></script>

<!--[if IE 6]>
<script type="text/javascript" src="js/ie6png.js" ></script>
<script type="text/javascript">
DD_belatedPNG.fix('div,ul,li,a,p,img,body,dl,dt,dd');</script>
<![endif]-->
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
<script type="text/javascript">
$(document).ready(function(){
	var customer_id,userId;
//取值正确
////////////////////////////////////////////////////////////////////////////
var urlinfo = window.location.href;//获取url  
//alert(urlinfo);
customer_id=urlinfo.split("=")[1].split("&")[0];
//alert("id:"+clientId);
var client = urlinfo.split("?")[1].split("=")[2];//拆分url得到”=”后面的参数  
//alert(decodeURI(client));  
/////////////////////////////////////////////////////////////////////////////
var customer_name=decodeURI(client);
$("#customer_name").val(customer_name);
$("#customer_id").val(customer_id);
});

//添加
    function ajaxPost(){
    	//alert("reception_mode"+$("input[name='reception_mode']:checked").val());
    	//alert("reception_content"+$("#reception_content").val());
    	//alert("name"+$("#name").val());
    	//alert("userAccount"+$("#userAccount").val()); 
    	//alert("userId"+$("#userId").val());
    	//alert("clientId"+$("#clientId").val());
    	var receive={
    		reception_mode:$("input[name='reception_mode']:checked").val(),
    		reception_content:$("#reception_content").val(),
    		customer_id:$("#customer_id").val(),
    		customer_name:$("#customer_name").val(),
    		user_id:$("#number").val(),
    		user_name:$("#name").val()
    		
    	};
    	
    	//alert("receive："+receive);
        $.ajax({ 	
        data: receive,
        type:"Post",  
        dataType: 'json',  
        url:"./Reception_Record/addReception_Record.do", 
        error:function(data){   
             alert("出错了！！");  
        },  
        success:function(data){
        	alert('接待记录添加成功！');
        	 window.location.replace("listReception_Record.jsp");
        	//window.locatinon.href = 'listReception_Record.jsp'; 
         }  
         });  
     } 
    // 重置
    function ajaxReset(){

    	$("input:radio[name='reception_mode']").eq(0).attr("checked",true);
    	//$("#userAccount").val("");
    	$("#name").val("");
    	$("#reception_content").val("");
		
    }
</script>
<script type="text/javascript">
   function checkreception_content(){
	  var reception_content= $("#reception_content").val();
	  if(reception_content==""){
		 alert("接待内容不能为空！"); 
		 $("#reception_content").focus();
		 return false;
	  }
	  return true;
   }
</script>
<script type="text/javascript">
function select(){
var SearchSql;
var user_id= $("#user_id").val();
//alert(user_id);
if(user_id!=""){
	SearchSql=" and u.user_id='"+user_id+"'";
}
	
	//alert("123");
	//alert("ceach:"+SearchSql);
	$.ajax({
    	url:"Reception_Record/selectAll.do",
        datatype:'json', 
        data:{'page':1,'rows':1,'SearchSql':SearchSql}, // 发送数据   
        error:function(data){  
            alert("出错了！！");  
       },  
       success:function(data){
    	   var parentdiv=$('<div style="position: absolute; top: 29%; left: 55%;"></div>');        //创建一个父div
    	    parentdiv.attr('id','parent');        //给父div设置id
    	    var strchild = '';
    	    for(var a = 0 ;a<data.rows.length;a++){
    	    //	console.log(data.rows[a].user_name);
    	   	strchild ='<option value='+data.rows[a].user_id+'>'+data.rows[a].user_name+'</option>'+ strchild
    	    }  	    
    	    var Str = '<div><select>'+strchild+'</select></div>';
    	    var childdiv=$(Str);   
    	    childdiv.appendTo(parentdiv);
    	    parentdiv.attr('position','relative; z-index:99999');       
    	    //给子div设置id
    	   
    	    parentdiv.appendTo('body');            //将父div添加到body中
       	//alert('业务员信息查询成功！');
       //	window.location.href = 'listclient.jsp'; 
       	//alert("ffff"+data);
       	//console.log("---------"+data);
       	var len=data.rows.length;
       	//alert("user_id:"+data.rows.length);
       	if(len>0){
       		//alert( data.rows[0].id);
           	//alert( data.rows[0].name);
           	$("#user_id").val(data.rows[0].id),
           	$("#name").val(data.rows[0].name)
       	}else{
       		alert("这个业务员不存在！！！");
       		$("#user_id").val("");
       		$("#name").val("");
       		$("#user_id").focus();
       	}
       	
       }
 
        });
}
</script>
</head>
<body>
<div class="yboxwidth boxcenter">
  <div class="ybox09">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <td style="padding-left: 20px"><table border="0" cellspacing="0" cellpadding="0">
          <tr valign="top" >
            <td class="ybox11td5" ></td>
            <td class="ybox11td6" >填写接待客户信息</td>
            <td class="ybox11td7"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td4"></td>    
          </tr>
        </table></td>
        </tr>
    </table>
  </div>
  <div class="ybox02">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="margb4">
      <tr>
        <td class="ybox03td1"></td>
        <td class="ybox03td2"></td>
        <td class="ybox03td3"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5"><div class="ybox05 margb8">
            <dl>
              <dt><strong>接待基本信息</strong> </dt>
            </dl>
            <input type="hidden" id="user_id" name="user_id" />
            <input type="hidden" id="customer_id" name="customer_id"  />
          </div>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
            <tr>
              <td width="15%" class="ybox04tdl"><span class="red">*</span>接待方式</td>
              <td width="18%" class="ybox04tdr">
                  <input type="radio" name="reception_mode" value="来电" checked="checked"/>来电 &nbsp;&nbsp;&nbsp;
                  <input type="radio" name="reception_mode" value="来访"/>来访
              </td>
             <td width="15%" class="ybox04tdl">客户姓名</td>
              <td width="18%" class="ybox04tdr">
                  <input id="customer_name" name="customer_name"type="text"  class="black12" style="width:90%;" disabled="disabled" />
              </td>
              <td width="33%" class="ybox04tdl" colspan="2"></td>
            </tr>
          </table></td>
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5">
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
             
            <tr>
                 
              <td width="15%" class="ybox04tdl"> 业务员姓名</td>
              <td width="18%" class="ybox04tdr">
              <input name="name" type="text"  class="black12" id="name" style="width:90%;"  />
               <img src="images/select.gif"  style="cursor: pointer;" onclick="select()" />
               </td>
                  <td width="15%" class="ybox04tdl">业务员编号</td>
              <td width="18%" class="ybox04tdr">
              <input name="number" type="text"  class="black12" id="number" style="width:85%;" /></td>
                        <td width="33%" colspan="2" class="ybox04tdl"></td>  
             </tr>
              <tr>
                  <td width="15%" class="ybox04tdl" style="padding-bottom: 65px"><span class="red">*</span> 接待内容</td>
                  <td width="18%" class="ybox04tdr" colspan="5">
                     <textarea rows="5" cols="150" name="reception_content" id="reception_content"></textarea>
                  </td>
                  
              </tr>
              <tr><td class="ybox04tdr" colspan="6">
               <dl>
                 <dt><strong>【注】</strong> 
                 1.基本信息为必填项</br>
                 2.详细信息必须在用户下订单之前填写完整
              </dt>
               </dl>
            </td>
            </tr>
            
          </table></td>
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td7"></td>
        <td class="ybox03td8"></td>
        <td class="ybox03td9"></td>
      </tr>
    </table>
    <table width="380" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="60" align="center"> <img src="images/bottoncommit.gif"  style="cursor: pointer;"width="95" height="34" onclick="return checkreception_content()&&ajaxPost()" /></td>
        <td height="60" align="center"><img src="images/bottonreset.gif" style="cursor: pointer;" width="95" height="34" onclick="ajaxReset()" /></td>
      </tr>
    </table>
  </div>
</div>
</body>
</html>
